package kz.pompei.ifacer.model.widgets;

import java.awt.Rectangle;
import java.io.PrintStream;
import java.util.UUID;

public abstract class WidgetRect extends Widget {
  public int width = 100, height = 50;
  
  public WidgetRect() {
    super();
  }
  
  public WidgetRect(UUID uuid) {
    super(uuid);
  }
  
  public Rectangle rect() {
    return new Rectangle(x, y, width, height);
  }
  
  public void takeRect(WidgetRect w) {
    takePosition(w);
    width = w.width;
    height = w.height;
  }
  
  @Override
  public void assignTo(Widget widget) {
    checkWidget(widget, WidgetRect.class);
    super.assignTo(widget);
    WidgetRect w = (WidgetRect)widget;
    w.width = width;
    w.height = height;
  }
  
  @Override
  protected void printFields(int offset, PrintStream out) {
    String s = space(offset);
    out.println(s + "<width v=\"" + width + "\" />");
    out.println(s + "<height v=\"" + height + "\" />");
  }
}
